package com.fengzai.jdkproxy;

import sun.misc.ProxyGenerator;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Created by  峰仔  on 2017-08-03
 */
public class Test {
    public static void main(String[] args) {
        Zhongjie zhongjie = new Zhongjie();
        Fangdong instance = (Fangdong) zhongjie.getInstance(new FangdongImpl("张三"));
        instance.chuzu();
        byte[] bytes = ProxyGenerator.generateProxyClass("$Proxy0", new Class[]{Fangdong.class});
        try (FileOutputStream fileOutputStream = new FileOutputStream("E:\\tengxunketang\\fengzai-proxy\\src\\main\\java\\com\\fengzai\\jdkproxy\\$Proxy0.class");) {

            fileOutputStream.write(bytes);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
